using System;
using System.Collections.Generic;
using System.Text;

namespace LeisureCenter.Api.Tools
{
    public class Disposable : IDisposable
    {
        protected bool disposed = false;

        ~Disposable()
        {
            Dispose(false);
        }

        #region IDisposable Membres

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        #endregion

        protected virtual void Dispose(bool disposing)
        {
            disposed = true;
        }

        public static void DisposeIfApplicable(object obj)
        {
            if (obj is IDisposable)
            {
                ((IDisposable)obj).Dispose();
            }
        }
    }
}
